package com.naishuo.bigevent.validation;

import com.naishuo.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class StateValidation implements ConstraintValidator<State, String> {

    @Override
    public void initialize(State constraintAnnotation) {
        // 初始化逻辑，如果有的话
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null) {
            return false; // 添加对 null 值的处理
        }
        return "草稿".equals(value) || "已发布".equals(value);
    }
}